from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean
from sqlalchemy.orm import relationship

from datetime import datetime

from ..db import Base


# 用户模型
class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    password_hash = Column(String, nullable=False)
    email = Column(String, unique=True, nullable=False)
    created_at = Column(DateTime, default=datetime.utcnow)

    vip = Column(Boolean, default=False)  # 默认不是VIP
    disk_quota = Column(Integer, default=1024*1024*10)  # 默认10MB
    disk_used = Column(Integer, default=0)  # 默认0

    # 关联关系，一个用户可以有多个文件和文件夹
    files = relationship("File", back_populates="owner", cascade="all, delete-orphan")
